package org.jeecg.modules.friends.service.impl;

import java.util.List;

import org.jeecg.modules.friends.dao.SchoolMetaDataDAO;
import org.jeecg.modules.friends.metainfo.param.SchoolListQueryParam;
import org.jeecg.modules.friends.model.SchoolMetaDataDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

@Service
public class SchoolMetaDataServiceImpl implements org.jeecg.modules.friends.service.SchoolMetaDataService {
    @Autowired
    private SchoolMetaDataDAO schoolMetaDataDAO;

    @Override
    public Page<SchoolMetaDataDO> page(SchoolListQueryParam queryParam) {
        List<SchoolMetaDataDO> schoolMetaDataDOS = schoolMetaDataDAO.getSchoolMetaDataDOS(queryParam);
        Page<SchoolMetaDataDO> page = new Page<>(queryParam.getPageNo(), queryParam.getPageSize());
        page.setTotal(countRecords(queryParam));
        page.setRecords(schoolMetaDataDOS);
        return page;
    }
    private Long countRecords(SchoolListQueryParam queryParam) {
       return  schoolMetaDataDAO.countByParam(queryParam);
    }
}